package com.youaishujuhui.devops.web.domain.game;

import java.util.Date;

import org.nutz.dao.entity.annotation.ColDefine;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Comment;
import org.nutz.dao.entity.annotation.Default;
import org.nutz.dao.entity.annotation.EL;
import org.nutz.dao.entity.annotation.Id;
import org.nutz.dao.entity.annotation.Index;
import org.nutz.dao.entity.annotation.One;
import org.nutz.dao.entity.annotation.Prev;
import org.nutz.dao.entity.annotation.Table;
import org.nutz.dao.entity.annotation.TableIndexes;

import com.youaishujuhui.devops.web.domain.channel.Channel;
import com.youaishujuhui.devops.web.domain.host.Host;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Table("t_game_process")
@TableIndexes({@Index(name="idx_gameId_serverId",fields={"gameId", "serverId"},unique = true),
	@Index(name="idx_dir",fields={"dir"},unique = true)})
@Getter
@Setter
@ToString
public class GameProcess {

	@Id
	@Comment("游戏服id")
    private int gpId;
	
	@Column
	@ColDefine(notNull = true)
	@Comment("关联的游戏id")
	private int gameId;
	
	@One(field = "gameId")
	private Game game;
	
	@Column
	@ColDefine(notNull = true)
	@Comment("关联的渠道id")
	private int channelId;
	
	@One(field = "channelId")
	private Channel channel;
	
	@Column
	@ColDefine(notNull = true)
	@Comment("关联的主机id")
	private int hostId;
	
	@One(field = "hostId")
	private Host host;

	@Column
	@ColDefine(notNull = false)
	@Comment("游戏名")
	private String name;
	
	@Column
	@ColDefine(notNull = true)
	@Comment("游戏服id")
	private int serverId;
	
	@Column
	@ColDefine(notNull = true)
	@Comment("游戏服目录")
	private String dir;
	
	@Column
	@ColDefine(notNull = true)
	@Comment("游戏进程端口")
	private int gamePort;
	
	@Column
	@ColDefine(notNull = true)
	@Comment("gm端口")
	private int gmPort;
	
	@Column
	@ColDefine(notNull = false)
	@Comment("域名")
    private String domain;
	
	@Column
	@ColDefine(notNull = true)
	@Default("0")
	@Comment("状态(1:开服中,0:关服,-1:已删除)")
	private int state;
    
    @Column
    @Prev(els = @EL("now()"))
    @Comment("安装时间")
    private Date createTime;
    
    @Column
    @ColDefine(notNull = false)
    @Comment("下线时间")
    private Date offTime;
}
